package cn.xclink.business.controller;
import java.util.List;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


import cn.xclink.business.entity.MonthEntity;
import cn.xclink.common.entity.ConnomCount;
import cn.xclink.common.util.DateUtil;
import cn.xclink.common.web.bind.annotation.CurrentUser;
import cn.xclink.kernel.entity.User;
import cn.xclink.kernel.service.UserService;

@Controller
@RequestMapping("business/ubiao")
public class TestController {

	public static String LEFT_DIVID = "bus_biao_left_div";
	public static String RIGHT_DIVID = "bus_biao_right_div";

	@ModelAttribute
	public void init(Model model) {
		model.addAttribute("left_divid", LEFT_DIVID);
		model.addAttribute("right_divid", RIGHT_DIVID);
	}


	@Autowired
	private  UserService userService;
	@RequestMapping
	public String index(@CurrentUser User currentUser, Model model,
			HttpServletRequest request) {
		return "business/biao/index";
	}

	@RequestMapping("biao")
	public String tbiao(){
		return "business/biao/pie";
	}
	@RequestMapping("list")
	@ResponseBody
	/**
	 * 
	 * @param model
	 * @return
	 */
	public List<ConnomCount>  tobiao(Model model){
		String year="2018";
		MonthEntity monthEntity=userService.selectMonth(year);
		return DateUtil.toJson(monthEntity,year);

	}

}

